home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / ultra250.zip / UW_HELP6.HLP < prev    next >
Text File  |  1992-11-13  |  22KB  |  512 lines

  1. `co(4,7);──────────────────────────── /// Print Support ───────────────────────────────`co();
  2.  
  3.                                `keyword(Introduction,/// Introduction);
  4.                            `keyword(Key Structure Elements,/// Key Structure Elements);
  5.  
  6.  ┌──────────────────────────────────────────────────────────────────────────┐    
  7.  │               `keyword(init_printer,/// init_printer);                `keyword(end_printer,/// end_printer);                    │
  8.  │               `keyword(print_char,/// print_char);                  `keyword(print_data,/// print_data);                     │
  9.  │               `keyword(print_eol,/// print_eol);                   `keyword(print_file,/// print_file);                     │
  10.  │               `keyword(print_screen,/// print_screen);                `keyword(print_str,/// print_str);                      │
  11.  │               `keyword(print_window,/// print_window);                `keyword(realloc_printer,/// realloc_printer);                │
  12.  │               `keyword(set_prt_xlat,/// set_prt_xlat);                `keyword(print_in_bkgrnd,/// print_in_bkgrnd);                │
  13.  └──────────────────────────────────────────────────────────────────────────┘
  14.  
  15. `co(4,7);─────────────────────────── /// Introduction ─────────────────────────────────`co();
  16.  
  17.       These routines are primarily designed for printing to a printer.
  18.     However, printing can be output to a DOS file or device (com1, lpt1,
  19.     tmp.dat, etc).  UltraWin can have as many as four print queues active and
  20.     printing concurrently!  The queuing routines are unique in the fact that
  21.     they can "dynamically" reallocate themselves and "grow" and "shrink" on the
  22.     fly without losing a single byte of data.  The reallocation routines take
  23.     advantage of the lightning fast movmem, as much out of convenience as
  24.     speed.  An 8Mhz 286 can queue 25,000 bytes worth of text strings in one
  25.     second, reallocating every 2048 bytes; really quite remarkable.  The
  26.     output is very fast.  Under normal operation, a "write" occurs on every
  27.     byte, resulting in ~1024 bytes per second (on the same machine).  Not many
  28.     printers can keep up with this speed!  Even greater speed is achieved by
  29.     using "block mode", where each write can output 512 bytes at a time.  This
  30.     is not done by default since outputting to a comm port at a slow baud rate
  31.     could hamper overall performance.
  32.  
  33. `color(RED,LIGHTGRAY);─────────────────────── /// Key Structure Elements ───────────────────────────`color();
  34.  
  35.       Several print structure elements are of importance.  These elements can
  36.     be modified directly for the desired effect.
  37.      
  38.     The `co(15,1);halt`co(); member controls output from the queue.  If 1, output stops
  39.   and the data in the queue remains unmodified.  If set to 0, output
  40.   continues.
  41.  
  42.     The `co(15,1);block_mode`co(); member controls the number of bytes output per
  43.   call to the function "print_in_bkgnd".  If 0, only one byte per call will
  44.     be output.  This is useful for communication devices or printers.  If
  45.     outputting to a file or laser printer, setting block mode to 1 will allow
  46.     up to 512 bytes to be output per call, thereby increasing performance.
  47.     This value is defined in UW.H.  Changing this value and recompiling
  48.     UW_PRINT.C will allow you to change the number of bytes sent per block.
  49.  
  50.         The `co(15,1);xlat`co(); and `co(15,1);xlat_flag`co(); control printer translation.  See `keyword(set_prt_xlat,/// set_prt_xlat);
  51.     for more details.
  52.  
  53. `co(10,1);/// init_printer`co();   `keyword(source,[UW_PRINT.C]~init_printer);
  54.       Initializes a printer queue.  Printer queues can be either ram-based or
  55.     disk-based. If ram-based, a queue can be no greater than 64k.  Disk-based
  56.     queues can be up to 2 gigabytes. (Though we have never actually tried this
  57.     size!).  If disk-based, the initial and maximum size should be set to the
  58.     same value, and a second filename is used as a disk buffer.  Be sure that
  59.     the isize and msize values are "long". If any error occurs (file cannot be
  60.     open, memory cannot be allocated,etc) a 0 will be returned.
  61.  
  62. Prototype:
  63.     int init_printer( char *fname, char *diskbuff, long isize,
  64.                                         long msize, PRINT *p );
  65.  
  66. Parameters:
  67. `co(11,1);    char  *fname`co();
  68.         A pointer to a string containing the filename/device to print to.
  69. `co(11,1);    char  *diskbuff`co();
  70.         A pointer to a string containing the filename/device to use as a disk
  71.     buffer.  This is NULL for ram-based queues.
  72. `co(11,1);    long  isize`co();
  73.         The initial size of the print queue. (Maximum 64k if ram based)
  74. `co(11,1);    long  msize`co();
  75.         The maximum size of the print queue. (Maximum 64k if ram based)
  76.         isize and msize should be set equal if using a disk based queue.
  77. `co(11,1);    PRINT *p`co();
  78.     A pointer to a print queue structure.   
  79.  
  80. Usage:
  81.     PRINT printer1, printer2;
  82.     ...
  83.     if( !init_printer("out1.prt", NULL, 2048L, 16384L, &printer1) )
  84.         wn_plst(0,0,"cannot initialize printer", wnp);
  85.     if( !init_printer("out2.prt", "disk.buf", 32768L, 32768L, &printer2) )
  86.         wn_plst(0,0,"cannot initialize printer", wnp);
  87.  
  88. `co(10,1);/// end_printer`co();   `keyword(source,[UW_PRINT.C]~end_printer);
  89.       Closes any files and frees any memory used by the print queue.  If
  90.     disk-based, the temporary disk file is left intact so that it will not
  91.     have to be recreated during the next program execution. You may delete
  92.     this file yourself if desired.
  93.  
  94. Prototype:
  95.     int end_printer( PRINT *p );
  96.  
  97. Parameters:
  98. `co(11,1);    PRINT *p`co();
  99.     A pointer to a print queue structure.   
  100.  
  101. Usage:
  102.     PRINT printer1;
  103.     ...
  104.     end_printer(&printer1);
  105.  
  106. `co(10,1);/// print_char`co();   `keyword(source,[UW_PRINT.C]~print_char);
  107.       Prints a single character.     A 0 is returned if an error occurs.
  108.  
  109. Prototype:
  110.     int print_char( uchar c, PRINT *p );
  111.  
  112. Parameters:
  113. `co(11,1);    uchar c`co();
  114.     A single byte to queue for printing.   
  115. `co(11,1);    PRINT *p`co();
  116.     A pointer to a print queue structure.   
  117.  
  118. Usage:
  119.     PRINT printer1;
  120.     ...
  121.     print_char('\r', &printer1);
  122.  
  123. `co(10,1);/// print_data`co();   `keyword(source,[UW_PRINT.C]~print_data);
  124.       Prints a block of data.  A 0 is returned if an error occurs.
  125.  
  126. Prototype:
  127.     int print_data( uchar *data, int cnt, PRINT *p );
  128.  
  129. Parameters:
  130. `co(11,1);    uchar *data`co();
  131.     A pointer to the data to queue for printing.   
  132. `co(11,1);    int   cnt`co();
  133.     The number of bytes to print.   
  134. `co(11,1);    PRINT *p`co();
  135.     A pointer to a print queue structure.   
  136.  
  137. Usage:
  138.     uchar data[132];
  139.     PRINT printer1;
  140.     ...
  141.     print_data(data, 132, &printer1);
  142.  
  143. `co(10,1);/// print_eol`co();   `keyword(source,[UW_PRINT.C]~print_eol);
  144.       Prints an end-of-line sequence.  The print structure contains two
  145.     variables, "cr_cnt" and "lf_cnt" that control this sequence.  For every
  146.     carriage return "cr_cnt", "lf_cnt" line feeds are printed.
  147.     
  148.         For instance, the simple case of cr_cnt = lf_cnt = 1 outputs \r\n  while
  149.     cr_cnt = 1, lf_cnt = 2 outputs \r\n\n.  A 0 is returned if an error
  150.     occurs.
  151.  
  152. Prototype:
  153.     int print_eol( PRINT *p );
  154.  
  155. Parameters:
  156. `co(11,1);    PRINT *p`co();
  157.     A pointer to a print queue structure.   
  158.  
  159. Usage:
  160.     PRINT printer1;
  161.     ...
  162.     print_eol(&printer1);
  163.  
  164. `co(10,1);/// print_file`co();   `keyword(source,[UW_PRINT.C]~print_file);
  165.       Prints an entire file.  The file is queued in "raw" format, no CR/LF
  166.     translation occurs.  Make sure that there is enough room in the queue to
  167.     hold the entire file.  A 0 is returned if an error occurs.
  168.  
  169. Prototype:
  170.     int print_file( char *fname, PRINT *p );
  171.  
  172. Parameters:
  173. `co(11,1);    char  *fname`co();
  174.         A pointer to a string containing the filename/device to print to.
  175. `co(11,1);    PRINT *p`co();
  176.     A pointer to a print queue structure.   
  177.  
  178. Usage:
  179.     PRINT printer1;
  180.     ...
  181.     print_file("uw_help6.hlp", &printer1);
  182.  
  183. `co(10,1);/// print_screen`co();   `keyword(source,[UW_PRINT.C]~print_screen);
  184.       Prints the contents of the entire screen.  A 0 is returned if an error
  185.     occurs.
  186.  
  187. Prototype:
  188.     int print_screen( PRINT *p );
  189.  
  190. Parameters:
  191. `co(11,1);    PRINT *p`co();
  192.     A pointer to a print queue structure.   
  193.  
  194. Usage:
  195.     PRINT printer1;
  196.     ...
  197.     print_screen(&printer1);
  198.  
  199. `co(10,1);/// print_str`co();   `keyword(source,[UW_PRINT.C]~print_str);
  200.       Prints a single NULL terminated string.  A 0 is returned if an error
  201.     occurs.
  202.  
  203. Prototype:
  204.     int print_str( uchar *str, PRINT *p );
  205.  
  206. Parameters:
  207. `co(11,1);    char  *str`co();
  208.         A pointer to the string to print.
  209. `co(11,1);    PRINT *p`co();
  210.     A pointer to a print queue structure.   
  211.  
  212. Usage:
  213.     PRINT printer1;
  214.     ...
  215.     print_string("This is a print string", &printer1);
  216.  
  217. `co(10,1);/// print_window`co();   `keyword(source,[UW_PRINT.C]~print_window);
  218.       Prints the contents of the current window.  If the window is bordered
  219.     and the window parameter "inside" is 1, only the inside of the window is
  220.     printed.  If "inside" is 0, the entire window, including the border is
  221.     printed.  A 0 is returned if an error occurs.  Note that this works even
  222.     if the window is overlapped!
  223.  
  224. Prototype:
  225.     int print_window( WINDOW *wnp, PRINT *p );
  226.  
  227. Parameters:
  228. `co(11,1);    WINDOW *wnp`co();
  229.         A pointer to the window to print.
  230. `co(11,1);    PRINT  *p`co();
  231.     A pointer to a print queue structure.   
  232.  
  233. Usage:
  234.     PRINT printer1;
  235.     WINDOW wn;
  236.     ...
  237.     print_window(&wn, &printer1);
  238.  
  239. `co(10,1);/// realloc_printer`co();   `keyword(source,[UW_PRINT.C]~realloc_printer);
  240.       Is used internally to "grow" and "shrink" ram-based printer queues
  241.     dynamically.  A 0 is returned if an error occurs.
  242.  
  243. Prototype:
  244.     int realloc_printer( long new_size, PRINT *p );
  245.  
  246. Parameters:
  247. `co(11,1);    long new_size`co();
  248.         The new size, either greater or less than the current size.
  249. `co(11,1);    PRINT  *p`co();
  250.     A pointer to a print queue structure.   
  251.  
  252. Usage:
  253.     PRINT printer1;
  254.     ...
  255.     realloc_printer(32000L, &printer1);
  256.  
  257. `co(10,1);/// set_prt_xlat`co();   `keyword(source,[UW_PRINT.C]~set_prt_xlat);
  258.       Allows translation of the data through a 256-byte translation table.
  259.     For instance, the ASCII data queued can be printed as EBCDIC by pointing
  260.     this to the appropriate table.  Another example would be to point to a
  261.     table that contained ASCII equivalents to the IBM extended characters,
  262.     thereby providing support for older printers that do not support them.
  263.     Note that the translation occurs during output, not during the queuing
  264.     process.
  265.  
  266. Prototype:
  267.     void set_prt_xlat( int state, uchar *xlat, PRINT *p );
  268.  
  269. Parameters:
  270. `co(11,1);    int   state`co();
  271.         If 1, the translation table is activated, if 0 it is deactivated.
  272. `co(11,1);    uchar *xlat`co();
  273.         A pointer to the translation table.
  274. `co(11,1);    PRINT  *p`co();
  275.     A pointer to a print queue structure.   
  276.  
  277. Usage:
  278.     uchar xlat[256];
  279.     PRINT printer1;
  280.     ...
  281.     set_prt_xlat(1, xlat, &printer1);
  282.  
  283. `co(10,1);/// print_in_bkgrnd`co();   `keyword(source,[UW_PRINT.C]~print_in_bkgrnd);
  284.       Is the "heart" of the printer routines.  It actually scans the printer
  285.     queues and outputs the data to the appropriate file/device. You can call
  286.     this routine as often and as fast as you see fit, or let the idle function
  287.     call it in the "background".  There are no requirements as to when or how
  288.     often this routine is called, but the more frequent the better the printer
  289.     performance.  The total number of bytes output is returned.
  290.  
  291. Prototype:
  292.     int print_in_bkgrnd( void );
  293.  
  294. Parameters:
  295.  
  296. Usage:
  297.     ...
  298.     while( !kbhit() )
  299.         print_in_bkgrnd();
  300. OR
  301.     set_idle_func(print_in_bkgrnd);        /* wait event will call this for us */
  302.     do{
  303.             ...
  304.   }while(!end);
  305.  
  306. `co(4,7);───────────────────────── /// Timer/Sound Support ────────────────────────────`co();
  307.  
  308.       UltraWin has the additional capability of "taking over" the PC timer
  309.     interrupt.  It does this in a friendly manner by calling the old timer
  310.     vector at the proper rate.  UltraWin increases the timer interrupt rate by
  311.     a factor of 5, or approximately 91 ticks per second.  This allows you much
  312.     finer control over your programs.  We also provide you with an easy to use
  313.     timer facility for taking advantage of these features. UltraWin also
  314.     allows you to sound the PC speaker at a given frequency for a certain
  315.     amount of time and the timer interrupt will turn the speaker off for you.
  316.  
  317.         It is very important to remember to call end_clock before exiting
  318.     your program.  If you do not, you may experience strange crashes.
  319.   The function `co(11,1);end_video()`co(); calls `co(11,1);end_clock()`co(); to restore the vector and
  320.   clock rate if you forget to make the call.  Taking over the PC timer will
  321.   not affect the PC clock as the original interrupt is still called 18.2
  322.   times per second.  However, if your program or another program that 
  323.   controls your program also takes over the clock and changes the rate you
  324.   may experience some problems.  If this is the case, simply do not call
  325.   `co(11,1);init_clock()`co();.  You will not be able to use the timer variables or
  326.   call `co(11,1);tone()`co(); but `co(11,1);wait_ticks()`co(); will still operate normally.
  327.   
  328.   There are 4 seperate countdown timers available for use in your programs.
  329.   These are simply global variables that are decremented to 0 by the timer
  330.   interrupt.  For instance, to set a countdown timer that will reach 0
  331.   after 1 second, say `co(11,1);Uw_timers[0] = 91;`co(); You can then poll this
  332.   variable at your convenience to determine the time expired.  The
  333.   interrupt decrements the variable by 1 on each tick until the count
  334.   reaches 0, at which time it will remain 0.  The global variables
  335.   `co(11,1);Sys_timers`co(); and `co(11,1);Sound_timer`co(); should not be accessed as these are
  336.   used by UltraWin and its companion product InTUItion.
  337.   
  338. `co(10,1);/// init_clock`co();   `keyword(source,[UW_VID.C]~init_clock);
  339.       Takes over the PC timer interrupt and sets the timer rate to the desired
  340.     value.                                              
  341.  
  342. Prototype:
  343.     void init_clock( uint value );
  344.  
  345. Parameters:
  346. `co(11,1);    uint  value`co();
  347.     The countdown value for the PC timer chip.  0xffff is the standard
  348.     18.2 times per second. 0x7fff would increase the rate by 2, etc.
  349.     
  350. Usage:
  351.     ...
  352.      init_clock(0x3333);                                            /* speed up by factor of 5 */
  353.  
  354. `co(10,1);/// end_clock`co();   `keyword(source,[UW_VID.C]~end_clock);
  355.       Restores the timer interrupt and rate.  Be sure to call this function
  356.     before exiting your program.  `co(11,1);end_video()`co(); will call this for
  357.     you if you forget.
  358.  
  359. Prototype:
  360.     void end_clock();
  361.  
  362. Parameters:
  363.  
  364. Usage:
  365.     ...
  366.      end_clock();
  367.     end_mouse();
  368.     end_video();
  369.     exit(0);
  370.   
  371. `co(10,1);/// tone`co();   `keyword(source,[UW_VID.C]~tone);
  372.       Sounds the PC speaker at the desired frequency for the desired amount of
  373.     time measured in timer tics. (91/s).  There is no need to turn the sound
  374.     off, this is automatically handled by the timer interrupt.  It is
  375.     perfectly safe to call tone even if a tone is already in progress.  The
  376.     new frequency and time will override the current values.  If you need to
  377.     turn the speaker off before the time has expired you can call `co(11,1);sound_off();`co();
  378.  
  379. Prototype:
  380.     void tone( uint freq, int dur );
  381.  
  382. Parameters:
  383. `co(11,1);    uint  freq`co();
  384.     The desired frequency in hertz or cycles-per-second.   
  385. `co(11,1);    int    dur`co();
  386.     The duration of the tone in clock tics (91-per-second).
  387.  
  388. Usage:
  389.     ...
  390.   if( error )
  391.       tone(1024,9);                                                    /* sound at 1k for 1/10 second */
  392.  
  393. `co(4,7);───────────────────────── /// Ctrl-C/Ctrl-Break Control ───────────────────────`co();
  394.   
  395.       UltraWin takes over the Ctrl-C and Ctrl-Break handlers and installs
  396.     a dummy interrupt handler.  In this way, Ctrl-C can be used as any other
  397.     control key.  More importantly, your program will not abort without
  398.     restoring the clock interrupt.  If you need further control over these
  399.     handlers you can modify the ISR's `co(11,1);uw_ctrl_brk();`co(); and `co(11,1);uw_ctrl_c()`co();.
  400.     To prevent the bios from displaying ^C, UltraWin also takes over the
  401.     keyboard interrupt.  When a Ctrl-C or Ctrl-Break is seen, it is replaced
  402.     with a dummy code, 0x1e, which is later remapped back to Ctrl-C by
  403.     check_key.  This is all very confusing but necessary for proper handling.
  404.     The important thing to remember is that the user cannot "accidently"
  405.     break out of your program, yet you can capture these keystrokes and
  406.     exit normally if desired.
  407.  
  408. `co(4,7);──────────────────────────── /// Debugging Support ───────────────────────────`co();
  409.  
  410.                         `co(15,?);New "Source Trace" Libraries!`co();
  411.  
  412.     UltraWin V2.5 adds powerful debugging facilities.  The libraries now
  413.     come in two "flavors", the smaller standard production libraries, and the
  414.     new `co(15,?);Source Trace`co(); libraries.  The Source Trace libraries are used for
  415.     development, and the standard production libraries for the finished
  416.     product.
  417.   
  418.     When using the Source Trace libraries, UltraWin will check the validity
  419.     of most function parameters.  The most important of these are pointers to
  420.     UltraWin's structures; WINDOW, PRINT, and MENU.  UltraWin can detect when
  421.     you pass an invalid or uninitialized pointer to a function and will popup
  422.     an error window stating the function that detected the error and the
  423.     invalid pointer.  You can choose to exit the program in a safe and orderly
  424.     manner, or continue.  If you continue, do so at your own risk; you may
  425.     merely overwrite data on the screen, but you may also write over memory
  426.     outside of your program space and cause all sorts of nasty things, a
  427.     "lockup" being the least of these!
  428.   
  429.     UltraWin also checks many other parameters, such as cursor positioning,
  430.     border styles, window size, etc.  If a problem is detected, the error
  431.     window will appear.  This is even true for UltraWin window macros!  The
  432.     window macros that are used for many UltraWin operations are replaced with
  433.     functions in the Source Trace versions of the library.  This gives you
  434.     parameter validation for what normally is handled by the preprocessor.
  435.   
  436.     The error window shows a call log that displays the last 64 UltraWin
  437.   functions, the file and line number where they where called, and a count
  438.   of how many times they were called.  A call stack shows the internal calls
  439.   made by UltraWin.  For instance, if wn_plst calls mv_cs and mv_cs detects
  440.   and reports the error, the call stack will show that wn_plst called mv_cs.
  441.   mv_cs will not be placed in the call log since it was not called by your
  442.   program.  You can use the cursor keys to scroll up and down through the
  443.   call log.  The top entry (entry 1) is the oldest.  Even more exciting
  444.   than the call log is the fact that the error window can even display
  445.   the offending line in your source code!
  446.  
  447.     If you choose to exit when an error occurs, UltraWin will call exit(0).
  448.     exit() will close all open files, including files you have opened, and
  449.     will call all functions that are "registered" using atexit().  This
  450.     function allows you to "register" functions to be called by exit and is an
  451.     excellent cleanup technique.  Refer to you compiler's documentation for
  452.     further details.  UltraWin registers the end_video(), end_clock(), and
  453.     end_mouse() functions that correspond to init_video(), init_clock(), and
  454.     init_mouse().  These are all called automatically if you exit.
  455.  
  456.     To use the Source Trace libraries, simply link in the appropriate
  457.     library for your compiler, and define SOURCE_TRACE at the top of your "C"
  458.     file, before the inclusion of "uw.h".  Most compilers will allow you to
  459.     define it globally for a project, or at least give you the ability to
  460.     define it on the compilers command line.  Defining SOURCE_TRACE allows the
  461.     error window to display the line number of the file, the name of the file
  462.     in which the error was found, and even "pull up" the offending line from
  463.     the "C" file, if it is found in the current directory!  If you do not
  464.     define SOURCE_TRACE, but use the Source Trace version of the library, then
  465.     the error reporting will still be active, but no line number or file
  466.     information will be displayed and macro parameters will not be checked.
  467.  
  468.     When you are satisfied with your program, it is recommended that you
  469.     relink with the standard production library.  This will reduce code size
  470.     and increase performance.
  471.  
  472. `co(4,7);──────────────────────── /// Library Naming Conventions ──────────────────────`co();
  473.  
  474.     UltraWin supports many different compilers, and now with the Source Trace
  475.   feature the number of possible libraries has multiplied greatly.  To
  476.   make it easier to know which library goes with what compiler, we have
  477.   adopted a simple library naming convention.
  478.   
  479.     The first two letters of the library indicates the product, and are the
  480.   letters `co(15,?);UW`co(); for UltraWin.  The next letter(s) indicates the compiler,
  481.   as shown below:
  482.  
  483.     Compiler                Letters
  484.     ─────────────────────   ────────   
  485.     Turbo C                 `co(15,?);T`co();
  486.     Turbo C++               `co(15,?);TCP`co();
  487.     Borland C               `co(15,?);B`co();
  488.     Borland C++             `co(15,?);BCP`co();
  489.     Microsoft C             `co(15,?);M`co();
  490.     Microsoft C++           `co(15,?);MCP`co();
  491.     Mix Power C             `co(15,?);X`co();
  492.     Zortech C               `co(15,?);Z`co();
  493.     Zortech C++             `co(15,?);ZCP`co();
  494.  
  495.   The next letter indicates the library model, and is:
  496.  
  497.     Model                   Letter
  498.     ─────────────────────   ────────   
  499.     Small                   `co(15,?);S`co();
  500.     Medium                  `co(15,?);M`co();
  501.     Compact                 `co(15,?);C`co();
  502.     Large                   `co(15,?);L`co();
  503.  
  504.   Finally, if the library is a Source Trace "debug" version, the letter `co(15,?);D`co();
  505.     is appended.
  506.   
  507.     For example, the large model standard production library for Turbo C
  508.     would be `co(15,?);UWTL.LIB`co();, the small model Source Trace library for Turbo C would
  509.     be `co(15,?);UWTSD.LIB`co();, and the compact model Source Trace library for Borland C++
  510.     would be `co(15,?);UWBCPCD.LIB`co();.
  511.  
  512.